package tr.edu.metu.is.mega.server.service;

import java.util.List;

import tr.edu.metu.is.mega.client.service.GwtAnnouncementService;
import tr.edu.metu.is.mega.common.dto.AnnouncementDTO;
import tr.edu.metu.is.mega.common.dto.CourseDTO;
import tr.edu.metu.is.mega.server.business.AnnouncementManager;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;

/**
 * Implementation of GWT announcement service.
 */
public class GwtAnnouncementServiceImpl extends RemoteServiceServlet implements GwtAnnouncementService {

    private static final long serialVersionUID = 7892547058596401728L;

    private final AnnouncementManager manager;

    /**
     * Default constructor.
     */
    public GwtAnnouncementServiceImpl() {
        manager = new AnnouncementManager();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public AnnouncementDTO createAnnouncement(AnnouncementDTO announcement) {
        return manager.createAnnouncement(announcement);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public AnnouncementDTO updateAnnouncement(AnnouncementDTO announcement) {
        return manager.updateAnnouncement(announcement);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void deleteAnnouncement(AnnouncementDTO announcement) {
        manager.deleteAnnouncement(announcement);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public List<AnnouncementDTO> getAnnouncements(CourseDTO course) {
        return manager.getAnnouncements(course);
    }

}
